import request from '@/utils/request'

export function login(data) {
  // data.append('client_id', 'ynytapp')
  // data.append('client_secret', '111111')
  // data.append('captcha', 'abc')
  // data.append('checkKey', 'abc')
  return request({
    url: '/sys/login',
    method: 'post',
    // headers: {'Content-Type': 'multipart/form-data'},
    data
  })
}

export function logout() {
  return request({
    url: 'sys/loginout',
    method: 'post'
  })
}

// 验证签名
export function checkSignature(params) {
  return request({
    url: '/kmpt/sys/user_checkSignature',
    method: 'get',
    // requestBase:'VUE_APP_MANAGEMENT_API',
    params
  })
}

// 刷新token
export function refreshToken(data) {
  return request({
    url: '/login/refreshToken',
    method: 'post',
    data
  })
}

// 获取用户列表
export const userList = () => request({
  url: '/kmpt/sys/user_selectUsers',
  // requestBase:'VUE_APP_MANAGEMENT_API',
  method: 'get'
})

// 获取用户姓名
// export const userMap = (userIds) => request({
//   url: '/kmpt/sys/user/map',
//   method: 'post',
//   data: userIds
// })

// 获取用户列表
export const userMap = (userIds) => {
  userIds = userIds.filter(item => item)
  return request({
    url: '/kmpt/sys/user/map',
    method: 'post',
    data: { 'userIds': userIds.join(',') }
  })
}

// 用户修改密码
export const editPassword = (data) => request({
  url: '/kmpt/sys/user_changePassword',
  // requestBase:'VUE_APP_MANAGEMENT_API',
  method: 'post',
  data
})

// 用户修改签名
export const editSignature = (data) => request({
  url: '/kmpt/sys/user_changeSignature',
  // requestBase:'VUE_APP_MANAGEMENT_API',
  method: 'post',
  data
})

// 获取安全生产天数
export const safetydays = () => request({
  url: '/kmpt/biz/safetydays',
  // requestBase:'VUE_APP_BUSINESS_API',
  method: 'get'
})
// 岗位字典
export const postDict = () => request({
  url: '/kmpt/sys/post/dict',
  // requestBase:'VUE_APP_MANAGEMENT_API',
  method: 'get'
})
// 获取用户菜单
export const userMenu = (id) => request.get('/kmpt/sys/menu/user', {
  // requestBase:'VUE_APP_MANAGEMENT_API'
})

// 根据orgId获取所有用户
export function userByOrg(params) {
  return request({
    url: '/kmpt/sys/user_findByOrg',
    method: 'get',
    // requestBase:'VUE_APP_MANAGEMENT_API',
    params
  })
}

// 根据orgId获取所有用户
export function userByOrgNew(params) {
  return request({
    url: '/kmpt/sys/org/search/user',
    method: 'get',
    params
  })
}

// 根据orgId和postId获取
export function findByOrgAndPost(params) {
  return request({
    url: '/kmpt/sys/user/findByOrgAndPost',
    method: 'get',
    params
  })
}

//删除上传的签名
export function delSing(params) {
  return request({
    url: '/open/kmpt/biz/delete/sign',
    method: 'post',
    params
  })
}
